package mshandler

import (
	"github.com/Fengxq2014/aliyun/sms"
)

var (
	gatewayUrl      = "http://dysmsapi.aliyuncs.com/"
	accessKeyId     = "LTAIesk1SC8R2Pxi"
	accessKeySecret = "uMQKSf0gLtuoO4lKZ63q1ouwJsUW3v"
	signName        = "谭锐"
	templateCode    = "SMS_139976426"
)
//阿里云发送短信
func SendMs(phoneNumbers string, code string) (res sms.SendSmsResposeEntity, err error) {
	templateParam := "{\"code\":\"" + code + "\"}"
	sms := sms.NewAliyunSms(accessKeyId, accessKeySecret)
	return sms.SendSms(phoneNumbers, signName, templateCode, templateParam, "", "")
}

func QueryMs(phoneNumbers string, bizId string, sendDate string) (result sms.QuerySendDetailsResposeEntity, err error) {
	sms := sms.NewAliyunSms(accessKeyId, accessKeySecret)
	// phoneNumber 短信接收号码,如果需要查询国际短信,号码前需要带上对应国家的区号
	// bizID 发送流水号,从调用发送接口返回值中获取
	// sendDate 短信发送日期格式yyyyMMdd,支持最近30天记录查询
	// pageSize 页大小Max=50
	// currentPage 当前页码
	return sms.QuerySendDetails(phoneNumbers, bizId, sendDate, 10, 1)
}
